<?php
/**
 * Created by PhpStorm.
 *
 * Author : Traveler.
 * Time   : 2020/3/19 13:58
 * Company: Inner Mongolia Zhengzhi Network Technology Co., Ltd
 */

namespace app\admin\controller;


use app\admin\BaseController;
use app\admin\middleware\Auth;
use app\admin\middleware\Login;
use app\admin\model\Area as AreaModel;
use think\facade\View;

class Area extends BaseController
{
    /**
     * 控制器中间件
     * @var array
     */
    protected $middleware = [
        Auth::class => ['only' => ['add', 'edit', 'status', 'delete']],
        Login::class,
    ];

    /**
     * 接口：获取区域信息(表格渲染)
     * @return \think\response\Json
     */
    public function getTableData()
    {
        $param = $this->request->param();
        $data  = AreaModel::getAreaTable($param);

        return $this->success('获取区域信息成功', $data['data'], ['count' => $data['count']]);
    }

    /**
     * 接口：获取区域信息(下拉选择组件渲染)
     * @return \think\response\Json
     */
    public function getValidArea()
    {
        return json(AreaModel::getValidArea());
    }

    /**
     * 页面渲染：区域管理
     * @return string
     */
    public function index()
    {
        return View::fetch();
    }


}